#!/bin/bash

set -e
set -x

node_hosts_arr=()
iplist_path=config
i=0
while read -r line
do
    case $line in
        *'#'*)
            continue
        ;;
        *'end'*)
            break
        ;;
        *)
            IFS=',' read -ra parts <<< "$line"
        ;;
    esac
    
    pass="${parts[0]}" 
    address="${parts[1]}"
    hostname="${parts[2]}"
    if [ $address ];then
        node_hosts_arr[$i]="\"$hostname:9300\""
        let i=i+1
    fi
done < $iplist_path

node_hosts=$(printf "%s," "${node_hosts_arr[@]}")
node_hosts=${node_hosts%,}

set +x
set +e